home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Utils / Software2 / Product11 / Setup.exe / MT-3.16-full-en_US / mt-check.cgi < prev    next >
Text File  |  2005-04-18  |  10KB  |  301 lines

  1. #!/usr/bin/perl -w
  2.  
  3. # Copyright 2001-2005 Six Apart Ltd. This code cannot be redistributed without
  4. # permission from www.movabletype.org.
  5. #
  6. # $Id: mt-check.cgi.pre 10197 2005-03-09 00:27:57Z ezra $
  7. use strict;
  8.  
  9. local $|=1;
  10.  
  11. my($MT_DIR);
  12. BEGIN {
  13.     if ($0 =~ m!(.*[/\\])!) {
  14.         $MT_DIR = $1;
  15.     } else {
  16.         $MT_DIR = './';
  17.     }
  18.     unshift @INC, $MT_DIR . 'lib';
  19.     unshift @INC, $MT_DIR . 'extlib';
  20. }
  21.  
  22. local $| = 1;
  23.  
  24. use MT::L10N;
  25. my $LH = MT::L10N->get_handle('en_US');
  26.  
  27.     sub trans_templ {
  28.         my($text) = @_;
  29.         $text =~ s!<MT_TRANS((\s\w+=(["'])[^"]*\3)+)>!
  30.             my($msg, %args) = ($1);
  31.             #print $msg;
  32.             while ($msg =~ /(\w+)\s*=\s*(["'])(.*?)\2/g) {  #"
  33.                 $args{$1} = $3;
  34.             }
  35.             $args{params} = '' unless defined $args{params};
  36.             my @p = map MT::Util::decode_html($_),
  37.                     split /\s*%%\s*/, $args{params};
  38.             @p = ('') unless @p;
  39.             $LH->maketext($args{phrase}, @p);
  40.         !ge;
  41.         $text;
  42.     }
  43.  
  44. sub translate {
  45.     $LH->maketext(@_);
  46. }
  47.  
  48. print "Content-Type: text/html\n\n";
  49. print trans_templ(<<HTML);
  50.  
  51. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  52. <html xmlns="http://www.w3.org/1999/xhtml">
  53.  
  54. <head>
  55.     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  56.     <meta http-equiv="content-language" content="en" />
  57.     
  58.     <title><MT_TRANS phrase="Movable Type System Check"> [mt-check.cgi]</title>
  59.     
  60.     <style type=\"text/css\">
  61.         <!--
  62.         
  63.             body {
  64.                 font-family : Trebuchet MS, Tahoma, Verdana, Arial, Helvetica, Sans Serif;
  65.                 font-size : smaller;
  66.                 padding-top : 0px;
  67.                 padding-left : 0px;
  68.                 margin : 0px;
  69.                 padding-bottom : 40px;
  70.                 width : 80%;
  71.                 border-right : 1px dotted #8faebe;
  72.             }
  73.             
  74.             h1 {
  75.                 background : #8faebe;
  76.                 font-size: large;
  77.                 color : white;
  78.                 padding : 10px;
  79.                 margin-top : 0px;
  80.                 margin-bottom : 20px;
  81.                 text-align : center;
  82.             }
  83.             
  84.             h2 {
  85.                 color: #fff;
  86.                 font-size: small;
  87.                 background : #8faebe;
  88.                 padding : 5px 10px 5px 10px;
  89.                 margin-top : 30px;
  90.                 margin-left : 40px;
  91.                 margin-right : 40px;
  92.             }
  93.             
  94.             h3 {
  95.                 color: #333;
  96.                 font-size: small;
  97.                 margin-left : 40px;
  98.                 margin-bottom : 0px;
  99.                 padding-left : 20px;
  100.             }
  101.     
  102.             p {
  103.                 padding-left : 20px;
  104.                 margin-left : 40px;
  105.                 margin-right : 60px;
  106.                 color : #666;
  107.             }
  108.             
  109.             ul {
  110.                 padding-left : 40px;
  111.                 margin-left : 40px;
  112.             }
  113.             
  114.             .info {
  115.                 margin-left : 60px;
  116.                 margin-right : 60px;
  117.                 padding : 20px;
  118.                 border : 1px solid #666;
  119.                 background : #eaf2ff;
  120.                 color : black;
  121.             }
  122.         
  123.             .alert {
  124.                 padding : 15px;
  125.                 border : 1px solid #666;
  126.                 background : #ff9;
  127.                 color : black;
  128.             }
  129.             
  130.  
  131.             .ready {
  132.                 color: #fff;
  133.                 background-color: #9C6;
  134.             }
  135.  
  136.             .bad {
  137.                 padding-top : 0px;
  138.                 margin-top : 4px;
  139.                 border-left : 1px solid red;
  140.                 padding-left : 10px;
  141.                 margin-left : 60px;
  142.             }
  143.             
  144.             .good {
  145.                 color: #93b06b;
  146.                 padding-top : 0px;
  147.                 margin-top : 0px;
  148.             }
  149.         
  150.         //-->
  151.     </style>
  152.  
  153. </head>
  154.  
  155. <body>
  156.  
  157. <h1><MT_TRANS phrase="Movable Type System Check"> [mt-check.cgi]</h1>
  158.  
  159. <p class="info"><MT_TRANS phrase="This page provides you with information on your system\'s configuration and determines whether you have all of the components you need to run Movable Type."></p>
  160.  
  161.  
  162. HTML
  163.  
  164.  
  165. my $is_good = 1;
  166.  
  167. my @REQ = (
  168.     [ 'HTML::Template', 2, 1, translate('HTML::Template is required for all Movable Type application functionality.') ],
  169.  
  170.     [ 'Image::Size', 0, 1, translate('Image::Size is required for file uploads (to determine the size of uploaded images in many different formats).') ],
  171.  
  172.     [ 'File::Spec', 0.8, 1, translate('File::Spec is required for path manipulation across operating systems.') ],
  173.  
  174.     [ 'CGI::Cookie', 0, 1, translate('CGI::Cookie is required for cookie authentication.') ],
  175. );
  176.  
  177. my @DATA = (
  178.     [ 'DB_File', 0, 0, translate('DB_File is required if you want to use the Berkeley DB/DB_File backend.') ],
  179.  
  180.     [ 'DBD::mysql', 0, 0, translate('DBI and DBD::mysql are required if you want to use the MySQL database backend.') ],
  181.  
  182.     [ 'DBD::Pg', 0, 0, translate('DBI and DBD::Pg are required if you want to use the PostgreSQL database backend.') ],
  183.  
  184.     [ 'DBD::SQLite', 0, 0, translate('DBI and DBD::SQLite are required if you want to use the SQLite database backend.') ],
  185. );
  186.  
  187. my @OPT = (
  188.     [ 'HTML::Entities', 0, 0, translate('HTML::Entities is needed to encode some characters, but this feature can be turned off using the NoHTMLEntities option in mt.cfg.') ],
  189.  
  190.     [ 'LWP::UserAgent', 0, 0, translate('LWP::UserAgent is optional; It is needed if you wish to use the TrackBack system, the weblogs.com ping, or the MT Recently Updated ping.') ],
  191.  
  192.     [ 'SOAP::Lite', 0.50, 0, translate('SOAP::Lite is optional; It is needed if you wish to use the MT XML-RPC server implementation.') ],
  193.  
  194.     [ 'File::Temp', 0, 0, translate('File::Temp is optional; It is needed if you would like to be able to overwrite existing files when you upload.') ],
  195.  
  196.     [ 'Image::Magick', 0, 0, translate('Image::Magick is optional; It is needed if you would like to be able to create thumbnails of uploaded images.') ],
  197.  
  198.     [ 'Storable', 0, 0, translate('Storable is optional; it is required by certain MT plugins available from third parties.')],
  199.  
  200.     [ 'Crypt::DSA', 0, 0, translate('Crypt::DSA is optional; if it is installed, comment registration sign-ins will be accelerated.')],
  201.  
  202.     [ 'MIME::Base64', 0, 0, translate('MIME::Base64 is required in order to enable comment registration.')],
  203.  
  204.     [ 'XML::Atom', 0, 0, translate('XML::Atom is required in order to use the Atom API.')],
  205. );
  206.  
  207. use Cwd;
  208. my $cwd = '';
  209. {
  210.     my($bad);
  211.     local $SIG{__WARN__} = sub { $bad++ };
  212.     eval { $cwd = Cwd::getcwd() };
  213.     if ($bad || $@) {
  214.         eval { $cwd = Cwd::cwd() };
  215.         if ($@ && $@ !~ /Insecure \$ENV{PATH}/) {
  216.             die $@;
  217.         }
  218.     }
  219. }
  220.  
  221. my $ver = $^V ? join('.', unpack 'C*', $^V) : $];
  222. print trans_templ(<<INFO);
  223. <h2><MT_TRANS phrase="System Information:"></h2>
  224. <ul>
  225.     <li><strong><MT_TRANS phrase="Current working directory:"></strong> <code>$cwd</code></li>
  226.     <li><strong><MT_TRANS phrase="Operating system:"></strong> $^O</li>
  227.     <li><strong><MT_TRANS phrase="Perl version:"></strong> <code>$ver</code></li>
  228. INFO
  229.  
  230. ## Try to create a new file in the current working directory. This
  231. ## isn't a perfect test for running under cgiwrap/suexec, but it
  232. ## is a pretty good test.
  233. my $TMP = "test$$.tmp";
  234. local *FH;
  235. if (open(FH, ">$TMP")) {
  236.     print trans_templ("    <li><MT_TRANS phrase=\"(Probably) Running under cgiwrap or suexec\"></li>\n");
  237.     unlink($TMP);
  238. }
  239.  
  240. print "\n\n</ul>\n";
  241.  
  242. exit if $ENV{QUERY_STRING} && $ENV{QUERY_STRING} eq 'sys-check';
  243.  
  244. use Text::Wrap;
  245. $Text::Wrap::columns = 72;
  246.  
  247. for my $list (\@REQ, \@DATA, \@OPT) {
  248.     my $data = ($list == \@DATA);
  249.     my $req = ($list == \@REQ);
  250.     printf trans_templ('<h2><MT_TRANS phrase="Checking for"> %s <MT_TRANS phrase="Modules:">'."</h2>\n\t<div>\n"), $req ? trans_templ('<MT_TRANS phrase="Required">') :
  251.         $data ? trans_templ('<MT_TRANS phrase="Data Storage">') : trans_templ('<MT_TRANS phrase="Optional">');
  252.     if (!$req && !$data) {
  253.         print trans_templ(<<MSG);
  254.         <p class="info"><MT_TRANS phrase="The following modules are"> <strong><MT_TRANS phrase="optional"></strong>; <MT_TRANS phrase="If your server does not have these modules installed, you only need to install them if you require the functionality that the module provides."></p>
  255.  
  256. MSG
  257.     }
  258.     if ($data) {
  259.         print trans_templ(<<MSG);
  260.         <p class="info"><MT_TRANS phrase="The following modules are used by the different data storage options in Movable Type. In order run the system, your server needs to have"> <strong><MT_TRANS phrase="at least one"></strong> <MT_TRANS phrase="of these modules installed."></p>
  261.  
  262. MSG
  263.     }
  264.     my $got_one_data = 0;
  265.     for my $ref (@$list) {
  266.         my($mod, $ver, $req, $desc) = @$ref;
  267.         print "    <h3>$mod" .
  268.             ($ver ? " (version >= $ver)" : "") . "</h3>";
  269.         eval("use $mod" . ($ver ? " $ver;" : ";"));
  270.         if ($@) {
  271.             $is_good = 0 if $req;
  272.             my $msg = $ver ?
  273.                       trans_templ("<p class=\"bad\"><MT_TRANS phrase=\"Either your server does not have \">$mod <MT_TRANS phrase=\"installed, the version that is installed is too old, or \">$mod <MT_TRANS phrase=\"requires another module that is not installed.\" ") :
  274.                       trans_templ("<p class=\"bad\"><MT_TRANS phrase=\"Your server does not have\"> $mod <MT_TRANS phrase=\"installed, or \">$mod <MT_TRANS phrase=\"requires another module that is not installed.\"> ");
  275.             $msg   .= $desc .
  276.                       trans_templ(' <MT_TRANS phrase="Please consult the installation instructions for help in installing"> '.$mod.". </p>\n\n");
  277.             print wrap("        ", "        ", $msg), "\n\n";
  278.         } else {
  279.             print trans_templ("<p class=\"good\"><MT_TRANS phrase=\"Your server has\"> $mod <MT_TRANS phrase=\"installed (version \">@{[ $mod->VERSION ]}).</p>\n\n");
  280.             $got_one_data = 1 if $data;
  281.         }
  282.     }
  283.     $is_good &= $got_one_data if $data;
  284.     print "\n\t</div>\n\n";
  285. }
  286.  
  287. if ($is_good) {
  288.     print trans_templ(<<HTML);
  289.     
  290.     <h2 class="ready"><MT_TRANS phrase="Movable Type System Check Successful"></h2>
  291.  
  292.     <p><strong><MT_TRANS phrase="You\'re ready to go!"></strong> <MT_TRANS phrase="Your server has all of the required modules installed; you do not need to perform any additional module installations. Continue with the installation instructions."> <!-- If this is your first time configuring Movable Type on this system, you can now run <a href="./mt-load.cgi">mt-load.cgi</a>, and you <strong>must</strong> delete mt-load.cgi after it has successfully been run. --> </p>
  293.  
  294. </div>
  295.  
  296.  
  297. HTML
  298. }
  299.  
  300. print "</body>\n\n</html>\n";
  301.